<?

function CountRecord($table,$where="")
{
	global $con;
    if ($table=="") return false;
    if ($where=="") $where="1=1";
	$result = mysql_query("select count(*) as cnt from $table where $where",$con);
	$row=@mysql_fetch_assoc($result);
	return $row['cnt'];
}

//Count Page
function count_page($total, $n)
{
	if ($total%$n==0) return (int)($total/$n);
	return (int)($total/$n)+1;
}

//HAM NAY LOAI BO CAC LENH INJECTION
function killInjection($str){
	$bad = array("#","'",";","\\","=",":");
	$good = str_replace($bad,"", $str);
	return $good;
}

function islogin()
{
if (isset($_SESSION['user']) && $_SESSION['user']!='') return $_SESSION['user'];
return false;
}

function GetContent($id)
{
    global $con;
    if ($id=='') return false;
	$result = mysql_query("select * from contents where contents_id='$id' limit 1",$con);
	$row=mysql_fetch_assoc($result);
	return $row['contents_content'];
}	

function GetContentInfo($id)
{
    global $con;
    if ($id=='') return false;
	$result = mysql_query("select * from contents where contents_id='$id' limit 1",$con);
	$row=mysql_fetch_assoc($result);
	return $row;
}


function GetListContent()
{
    global $con, $session_ngonngu_admin;
    $ret=array();
	$result = mysql_query("select * from contents where langid='".$session_ngonngu_admin."' order by contents_order",$con);
	while (($row=mysql_fetch_assoc($result)))
	{
		$ret[]=array($row['contents_id'],$row['contents_name']);
	}
	return $ret;
}
?>